﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.UserInfoCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;
using System.Collections.Generic;

namespace SheepStorage.API.Application.CommandHandlers.UserInfoHandlers
{
    public class UserInfoShowHandlers : IRequestHandler<UserInfoShowCommand, Results<List<UserInfo>>>
    {

        private readonly IUserInfoService userInfoService   ;
        private readonly IMapper mapper;
        public UserInfoShowHandlers(IUserInfoService userInfoService, IMapper mapper)
        {
            this.userInfoService = userInfoService;
            this.mapper = mapper;
        }


        /// <summary>
        /// 查询所有  用户列表  
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results< List<UserInfo>>> Handle(UserInfoShowCommand  request, CancellationToken cancellationToken)
        {
           
           
           var userInfos = await userInfoService.GetUserInfo(request.UserTrueName, request.DepartmentId, request.StaffState);

           
            return   Results<List<UserInfo>>.DataResult(userInfos);
        }
    }
}
